package cn.itcast.n4_共享模型_管程;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

import static cn.itcast.util.Sleeper.sleep;

/**
 * <p>
 * Test40_ReentrantLock_可重入性
 * </p>
 *
 * @author flyduck
 * @since 2024-10-11
 */
@Slf4j(topic = "c.Test44_ReentrantLock_条件变量")
public class Test44_ReentrantLock_条件变量 {

    private static ReentrantLock reentrantLock = new ReentrantLock();

    public static void main(String[] args) throws InterruptedException {

        //创建一个新的条件变量
        Condition condition1 = reentrantLock.newCondition();
        Condition condition2 = reentrantLock.newCondition();

        reentrantLock.lock();
        condition1.await();//进入休息室等待


        condition1.signal();//叫醒某一个
        condition1.signalAll();//叫醒休息室的全部线程


    }
}
